﻿<!DOCTYPE html>
<html>
<head>
    <style type="text/css">
        p
        {
            margin-left: 10px;
            color: blue;
            width: 200px;
            cursor: pointer;
        }
        span
        {
            color: red;
            cursor: pointer;
        }
        div.abs
        {
            width: 50px;
            height: 50px;
            position: absolute;
            left: 220px;
            top: 35px;
            background-color: green;
            cursor: pointer;
        }
    </style>
    <script src="../jquery-1.8.0.js" type="text/javascript"></script>
</head>
<body>
    <div id="result">
        Click an element.</div>
    <p>
        This is the best way to <span>find</span> an offset.
    </p>
    <div class="abs">
    </div>
    <script type="text/javascript">
        $("*", document.body).click(function (e) {
            var offset = $(this).offset();
            e.stopPropagation();
            alert($(this)[0].tagName  +"  Top: "+ this.offsetTop + "  Left:" + this.offsetLeft);
            $("#result").text(this.tagName + " coords ( " + offset.left + ", " + offset.top + " )");              
        });

    </script>
</body>
</html>
